//
// Created by LiuYou on 2021/5/9.
//

#include <cstdio>
#include <cstdlib>
#include <dirent.h>


int main(int argc, char** argv) {
    const char* const PATTERN = "/etc";


    DIR* pDirStream = opendir(PATTERN);
    if (pDirStream == nullptr) {
        std::perror("opendir()");
        std::exit(1);
    }

    dirent* pDiRent;
    for (;;) {
        pDiRent = readdir(pDirStream);
        if (pDiRent != nullptr) {
            std::puts(pDiRent->d_name);
        } else {
            break;
        }
    }

    closedir(pDirStream);
    return 0;
}